#pragma once

#include <unordered_map>
#include <string>
#include <cpp_redis/cpp_redis>

using std::unordered_map;
using std::string;

namespace libzq
{
	namespace http
	{
		struct FileSessionStorage
		{
			void save(const string& key, const unordered_map<string, string>& data);
			unordered_map<string, string> load(const string& key);
			void remove(const string& key);
		};

		struct RedisSessionStorage
		{
			static void init(const char* host, unsigned short port, unsigned short timeout_msecs = 300, unsigned short max_reconnects = 3, unsigned short reconnect_interval_msecs = 30);
			static bool check();
			void save(const string& key, const unordered_map<string, string>& data);
			unordered_map<string, string> load(const string& key);
			void remove(const string& key);
		private:
			static cpp_redis::client _client;
			static bool _storage_has_inited;
		};
	}
}


